# -*- coding: utf-8 -*-
# 识别验证码
# opencv 实现

import cv2

class Verify(object):





    def verify_img(self, img):
        # 读取图片，并转化为灰度图
        image = cv2.imread(img, cv2.COLOR_BGR2GRAY)
        gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
        # 中值滤波
        GrayImage = cv2.medianBlur(gray_image, 5)
        # 二值化
        thresh = cv2.adaptiveThreshold(GrayImage, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 23, 1)




        cv2.imshow('image', thresh)
        cv2.waitKey()
        cv2.destroyAllWindows()




if __name__ == "__main__":
    img = './sources/verify_img/captcha-image_3.jpg'
    Verify().verify_img(img)



